﻿using Caliburn.Micro;
using SS.WPF.Framework.Localization;

namespace SS.WPF.Toolkit.PropertyEditor
{
    using System;
    using System.Globalization;
    using System.Linq;
    using System.Windows.Data;

    public class EnumTypeConverter : IValueConverter
    {
        #region Implementation of IValueConverter

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return null;
            }
            var values = Enum.GetValues(value.GetType());

            var translatedItems = (values.Cast<object>().ToDictionary(
                val => IoC.Get<TranslationManager>().Translate(val.ToString()) as string, x => x));
            return translatedItems;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion
    }

    public class EnumDisplayConverter : IValueConverter
    {
        #region Implementation of IValueConverter

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value;
        }

        #endregion
    }
}